package pl.pelcra.cesar.spider.webcrawler.interfaces;

import java.util.ArrayList;
import java.util.List;

/**
 * filter rules added to rules to filter urls
 * 
 * @author margielewski
 * 
 */
public class FilterRules {

	/**
	 * 
	 * @param filterRules
	 *            static constructor to copy filter rules
	 * @return return new object of FilterRules
	 */
	public static FilterRules newInstance(FilterRules filterRules) {
		if (filterRules != null) {
			FilterRules tmpFilterRules = new FilterRules();
			tmpFilterRules.listParameter = new ArrayList<Object>(
					filterRules.listParameter);
			return tmpFilterRules;
		}
		return null;
	}

	private List<Object> listParameter;

	/**
	 * public constructor of filter rules
	 */
	public FilterRules() {
		setListParameter(new ArrayList<Object>());
	}

	/**
	 * add parameter to filters
	 * 
	 * @param parameter
	 */
	public void addListParameter(Object parameter) {
		if (this.getListParameter() != null) {
			getListParameter().add(parameter);
		}
	}

	/**
	 * 
	 * @return return list of parameters
	 */
	public List<Object> getListParameter() {
		return this.listParameter;
	}

	/**
	 * 
	 * @param pos
	 *            integer position of parametr
	 * @return return parameter from the list at position pos
	 */
	public Object getListParameter(int pos) {
		if (this.listParameter != null) {
			return this.listParameter.get(pos);
		}
		return null;
	}

	/**
	 * set list of parameters
	 * 
	 * @param listParameter
	 */
	public void setListParameter(List<Object> listParameter) {
		this.listParameter = listParameter;
	}

}
